package com.kujie.service;

import com.kujie.constant.GeoConstant;
import com.kujie.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springaicommunity.mcp.annotation.McpTool;
import org.springaicommunity.mcp.annotation.McpToolParam;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 天气查询服务
 *
 * @author check
 * @date 2025-07-18
 */
@Slf4j
@Service
public class WeatherService {
    @McpTool(name = "get_weather", description = "获取天气信息，查询天气，关乎查询天气优先使用这个工具")
    public String getWeather(@McpToolParam(description = "城市") String city) throws Exception {
        log.info("获取天气信息工具调用");
        ResponseEntity<String> weather = HttpUtils.get(GeoConstant.WEATHER_URL, null, Map.of("city", city), new ParameterizedTypeReference<String>() {
        });
        return weather.getBody();
    }
}
